<html lang="en">
<head>
    <title>目的地管理</title>
    <#include "../common/header.ftl">
    <link rel="stylesheet" href="/js/plugins/treeview/bootstrap-treeview.min.css" type="text/css" />
    <script type="text/javascript" src="/js/plugins/treeview/bootstrap-treeview.min.js"></script>
    <script type="text/javascript">
        $(function () {
            //查看文章
            $('.lookBtn').click(function () {  //给查看文章绑定点击事件
                $('#inputModal .modal-body').empty(); //清空模态框
                var id = $(this).data('id'); //获取绑定在按钮上的id值
                $.get('/travel/getContentById',{id:id},function (data) {  //发送异步请求
                    $('#inputModal .modal-body').html(data.content);  //填充内容
                    $('#inputModal').modal('show');
                })
            })


            //查询
            $(".clickBtn").click(function () {
               /* var parentId = $(this).data("parentid");
                $("#parentId").val(parentId);*/
                $("#currentPage").val(1);
                $("#searchForm").submit();
            })

            //发布和拒绝
            $(".publicBtn").click(function () {
                var release = $(this).data("release");//获取绑定在按钮上的release值
                var id = $(this).data("id");//获取绑定在按钮上的id值
                $.get("/travel/changePublicValue", {release:release, id:id}, function (data) {  //发送异步请求
                    if(data.success){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })
        })
    </script>

    <style>
        #inputModal img{
            width: 100%;
        }
    </style>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="travel">

<div class="container-fluid " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">游记管理</h1>
                </div>
            </div>
            <#setting number_format="#">
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <#--<input type="hidden" name="parentId" id="parentId" value="${qo.parentId!}">-->
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!''}" placeholder="请输入名称">
                </div>
                <div class="form-group">
                    <label for="dept">状态:</label>
                    <select class="form-control" id="state" name="state">
                        <option value="-1">全部</option>
                        <option value="0">草稿</option>
                        <option value="1">待发布</option>
                        <option value="2">已发布</option>
                        <option value="3">已拒绝</option>
                    </select>
                    <script>
                        $("#state").val(${qo.state!});
                    </script>
                </div>
                <button type="button" class="btn btn-primary clickBtn" data-parentid="${qo.parentId!}"><span class="glyphicon glyphicon-search"></span> 查询</button>

            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>编号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
               <#list pageInfo.list as t>
                   <tr>
                       <td>${t_index+1}</td>
                       <td>${t.title}</td>
                       <td><img src="${t.coverUrl}" width="80px"/></td>
                       <td>${t.dest.name}</td>
                       <td>${t.author.nickname}</td>
                       <td>${t.stateDisplay}</td>
                       <td>
                           <#if  t.isPublic>
                            <a class="btn btn-success btn-xs publicBtn" href="javascript:;" data-release="0" data-id="${t.id}">
                                <span class="glyphicon glyphicon-minus-sign"></span> 下架
                            </a>

                           <#else>
                            <a class="btn btn-default btn-xs publicBtn" href="JavaScript:;" data-release="1" data-id="${t.id}">
                                <span class="glyphicon glyphicon-tag"></span>发布
                            </a>
                           </#if>
                           <a class="btn btn-info btn-xs lookBtn" data-id="${t.id}">
                               <span class="glyphicon glyphicon-pencil"></span> 查看文章
                           </a>
                       </td>
                   </tr>
               </#list>
            </table>
            <#--分页-->
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>

<!-- 模态框必须作为body的子标签 -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">查看游记内容</h4>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
</body>
</html>